package com.xiaoyuanxing.demo.controller;

import com.github.pagehelper.Page;
import com.xiaoyuanxing.demo.entity.School;
import com.xiaoyuanxing.demo.pojo.PageInfo;
import com.xiaoyuanxing.demo.service.SchoolService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/*
 **@author LuoShengYing
 **@date 2021/5/23
 */
@RestController
@RequestMapping("School")
public class SchoolController {
    @Resource(name = "schoolService")
    private SchoolService schoolService;

    /*
    * 获取全部学校数据
    * */
    @RequestMapping("getAllSchools")
    public PageInfo<School> getAllSchools(@RequestParam(defaultValue = "1",value = "pageNum") int pageNum,
                                          @RequestParam(defaultValue = "10",value = "pageSize") int pageSize){
        Page<School> schools = schoolService.getAllSchools(pageNum, pageSize);
        return new PageInfo<>(schools);
    }

    /*
    * 通过schoolID获取学院数组
    * */
    @RequestMapping("getColleges")
    public List<String> getColleges(int schoolID){
        return schoolService.getCollegesBySchoolID(schoolID);
    }
}
